#include "px_fileutility.h"


static PXINT32 _to_int(const char* bytes)
{
	return (PXINT32)(((unsigned char)bytes[3] << 24) |
		((unsigned char)bytes[2] << 16) |
		((unsigned char)bytes[1] << 8) |
		(unsigned char)bytes[0]);
}

static PXINT16 _to_short(const char* bytes)
{
	return (PXINT16)(((unsigned char)bytes[1] << 8) |
		(unsigned char)bytes[0]);
}


PXINT32 read_int_f(FILE * fp)
{
	char buffer[4];
	fread(buffer,1,4,fp);
	return _to_short(buffer);
}
PXINT16 read_short_f(FILE * fp)
{
	char buffer[2];
	fread(buffer,1,2,fp);
	return _to_short(buffer);
}

void     ignore_f(FILE * fp,PXINT32 offset)
{
	fseek(fp,offset,SEEK_CUR);
}